import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.sound.sampled.AudioInputStream;

import org.iforce2d.Jb2dJsonImage;
import org.jbox2d.dynamics.Body;

public abstract class GameObject {
	protected Jb2dJsonImage sourceImage;
	protected Body physicsProperties;
	protected AudioInputStream sound;

	public void draw(Graphics g) throws IOException {
		AffineTransform transform = new AffineTransform();
	    
	    double x = physicsProperties.getPosition().x;
	    double y = -physicsProperties.getPosition().y;
	    transform.translate(x*720+850, y*720+480-720);
	    /*if( physicsProperties.getAngle() > 0 )
	    	transform.rotate(physicsProperties.getAngle(), sourceImage..getHeight(GameScreen.createGameScreen())/2, sourceImage.getWidth(GameScreen.createGameScreen())/2);
	    else
	    	transform.rotate(physicsProperties.getAngle(), sourceImage.getHeight(GameScreen.createGameScreen()), sourceImage.getWidth(GameScreen.createGameScreen())/2);
	    ((Graphics2D)g).drawImage(sourceImage, transform, null);*/
	    ((Graphics2D)g).drawImage(ImageIO.read(new File(sourceImage.file)), (int)(physicsProperties.getPosition().x) , (int)(physicsProperties.getPosition().y), null);
	}
	
	public Body getPhysicsProperties(){
		return physicsProperties;
	}

	public abstract void update();

	public abstract void check();
}